import HTTP from '../util/http-p.js';
const app = getApp();

export default class BookModel extends HTTP {
  // 书籍的搜索
  search(start, q) {
    return this.request({
      url: app.globalData.url.book.bookSearch,
      data: {
        start,
        q
      }
    })
  }

  getHotList() {
    return this.request({
      url: app.globalData.url.book.hotList
    });
  }

  // 获取我的书籍数量
  getMyBookCount() {
    return this.request({
      url: app.globalData.url.book.myBookCount
    });
  }

  // 获取书籍详细信息
  getDetail(bid) {
    return this.request({
      url: app.globalData.url.book.detail(bid)
    });
  }

  // 获取某本书籍我的喜欢状态
  getLikeStatus(bid) {
    return this.request({
      url: app.globalData.url.book.likeStatus(bid)
    });
  }

  // 获得短评数组
  getComments(bid) {
    return this.request({
      url: app.globalData.url.book.comment(bid)
    });
  }

  // 发送短评
  postComments(bid, comment) {
    return this.request({
      url: app.globalData.url.book.shortComment,
      method: 'POST',
      data: {book_id:bid, content:comment}
    })
  }
}
